#include <iostream>
#include <signal.h>
#include <unistd.h>

void handler(int signo)
{
    std::cout << "捕捉一个信号 ： " << signo << std::endl;

    sigset_t pending;
    while (true)
    {
        sigpending(&pending);
        for (int i = 31; i >= 1; i--)
        {
            if (sigismember(&pending, i))
            {
                std::cout << "1";
            }
            else
                std::cout << "0";
        }
        sleep(1);
        std::cout << std::endl;
    }
}

int main()
{

    struct sigaction act;
    struct sigaction oact;
    act.sa_handler = handler;
    sigemptyset(&(act.sa_mask));
    sigaction(SIGINT, &act, &oact);

    while (true)
    {
        std::cout << "进程在运行" << std::endl;
        sleep(1);
    }
}